<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>确定文本在字符串中首次出现的位置 - indexOf()</title>
</head>

<body>
    <h1>JavaScript 字符串方法</h1>
    <p>indexOf() 方法返回指定文本首次出现的位置：</p>
    <p id="demo"></p>
    <script>
        var str = "The full name of China is the People's Republic of China.";
        var pos = str.indexOf("China");
        document.getElementById("demo").innerHTML = pos ;
    </script>
</body>

</html>